package com.xiaxiang.ar.ARCloud;

import android.app.Activity;
import android.util.Log;

import com.dg.acb.utils.configdata.XXConstants;
import com.okhttp.MyHttpUtils;
import com.xx.xiawan.net.DGRequestListener;
import com.xx.xiawan.net.GetRequest;

import org.json.JSONObject;

import java.io.IOException;

/**
 * Created by mk on 2017/10/25.
 */

public class ARCloudEditor {

    public ARCloudEditor(){

    }

    public static  void Register(Activity mActivity, JSONObject mJson,String url, String token, DGRequestListener listener){
        MyHttpUtils myHttpUtils = new MyHttpUtils();
        try {
            myHttpUtils.PostAsync(url,mJson.toString(),token,listener);
        } catch (IOException e) {
            e.printStackTrace();
        }

//        DGJsonRequest jsonRequest = new DGJsonRequest(mActivity, url,mJson,listener);
//        jsonRequest.startNoLock();
    }

    public static  void Query(Activity mActivity, String url, String token,DGRequestListener listener) {
        GetRequest getRequest = new GetRequest(url,mActivity,listener);
        getRequest.header("token",token);
        getRequest.startNoLock();
    }

    public static  void Query(Activity mActivity, String url, String token, MyHttpUtils.IMyHttpUtilsCallback listener) {
        MyHttpUtils myHttpUtils = new MyHttpUtils();
        try {
            myHttpUtils.GetCommonAsync(url,token,listener);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static  void Delete(Activity mActivity, String url, String token, DGRequestListener listener) {
        MyHttpUtils myHttpUtils = new MyHttpUtils();
        try {
            myHttpUtils.DeleteAsync(url, token, listener);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    public static  void GetKey(Activity mActivity, DGRequestListener listener) {
        String url = XXConstants.URI_GET_AR_KEY;
        Log.i("key",url);
        MyHttpUtils myHttpUtils = new MyHttpUtils();
        try {
            myHttpUtils.GetAsync(url,listener);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
